package org.dgt.model.core;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@Entity
@Table(name = "PRODUCT_PRICE_USER_REGISTRY", uniqueConstraints = @UniqueConstraint(columnNames = {"PRODUCT_ID", "USER_INFO_ID", "PRICE", "TYPE"}))
public class ProductPriceUserRegistry extends Base{
	@ManyToOne
	@JoinColumn(name = "PRODUCT_ID")
	private Product product;
	
	@ManyToOne	
	@JoinColumn(name = "USER_INFO_ID")
	private UserInformation userInfo;
	
	@Column(name = "PRICE")
	private float priceRegistry;
	
	@Column(name = "QUANTITY")
	private int quantity;
	
	@Column(name = "TYPE")
	private boolean sellerOrBuyer; //true is seller
	
	@Column(name = "NOTIFICATION_BY")
	private String notificationBy;
	
	/**
	 * This property is used in case that user registry price to buy a product, he can add price's offset +-
	 */
	@Column(name = "PRICE_OFFSET", columnDefinition = "integer default 0")
	private int priceOffset;
	
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	public float getPriceRegistry() {
		return priceRegistry;
	}
	public void setPriceRegistry(float priceRegistry) {
		this.priceRegistry = priceRegistry;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public boolean isSellerOrBuyer() {
		return sellerOrBuyer;
	}
	public void setSellerOrBuyer(boolean sellerOrBuyer) {
		this.sellerOrBuyer = sellerOrBuyer;
	}
	public String getNotificationBy() {
		return notificationBy;
	}
	public void setNotificationBy(String notificationBy) {
		this.notificationBy = notificationBy;
	}
	/**
	 * @return the priceOffset
	 */
	public int getPriceOffset() {
		return priceOffset;
	}
	/**
	 * @param priceOffset the priceOffset to set
	 */
	public void setPriceOffset(int priceOffset) {
		this.priceOffset = priceOffset;
	}
	public UserInformation getUserInfo() {
		return userInfo;
	}
	public void setUserInfo(UserInformation userInfo) {
		this.userInfo = userInfo;
	}
}
